#!/usr/bin/env python
# encoding: utf-8

import string
import logging

class PyHomeClass():
	confvars = {}
	logger = logging.getLogger('myApp')
	
	def __init__(self):
		self.initlogsys()

	def initlogsys(self):
		# create the CALL log level. It will be used for all incoming calls.
		logging.CALL = logging.INFO + 1
		logging.addLevelName(logging.CALL,'CALL')
		# create the logger object
		hdlr = logging.FileHandler('var/data.log')
		formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
		hdlr.setFormatter(formatter)
		self.logger.addHandler(hdlr)
		self.logger.setLevel(logging.INFO)
		print "Log System ON"

	def parseConfigFile(self, filename):
		f = open(filename, 'r')
		for line in f:
		    if line.find("=")!=-1:
 				line = line[:-1]        
 				line = line.replace(" ","")
 				if line[0]!='#':        
					self.confvars[line.split("=")[0]]=line.split("=")[1]

	def log(self,stringlog):
		print self.logger
		self.logger.log(logging.CALL, stringlog)

##Inizializzazione della classe PyhomeClass
sc = PyHomeClass()